package com.cuit.xsc.weishare.model;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.cuit.xsc.weishare.util.ConfigUtil;
import com.cuit.xsc.weishare.util.LogUtil;
import com.cuit.xsc.weishare.util.TextUtil;



public class Statuse
{
	private Long id;
	private String head;
	private String uName;
	private boolean isVerified;
	private String time;
	private String content;
	private String content_pic;
	private String from;
	private int redirect;
	private int comment;
	private long timestamp;
	private Statuse statuse;
	
	
	
	public Statuse()
	{
		super();
	}
	
	public Statuse(String json) throws JSONException
	{
		super();
		JSONObject jsonObject = new JSONObject(json);
        constructQQJson(jsonObject);
	}
	
	public Statuse(JSONObject jsonObject)
	{
		constructQQJson(jsonObject);
	}
	
	
	
	private void constructQQJson(JSONObject json)
	{
		try
		{
			LogUtil.e(this, "json="+json.toString());
			
			id = Long.parseLong(json.getString("id"));
			head = json.getString("head")+"/"+ConfigUtil.QQ_HEAD_IMAGE_SIZE;
			uName = json.getString("nick");
			int verified = json.getInt("isvip");
			if (verified == 0)
			{
				isVerified = false;
			}
			else if(verified == 1)
			{
				isVerified = true;
			}
			timestamp = json.getLong("timestamp");
			time = TextUtil.formatDate(timestamp);
			content = json.getString("text");
			String imArray = json.getString("image");
			if (imArray != null && !imArray.equals("") && !imArray.equals("null"))
			{
				//LogUtil.i(this, "imArray="+imArray);
				JSONArray jArray = new JSONArray(imArray);
				content_pic = jArray.getString(0)+"/"+ConfigUtil.QQ_IMAGE_SIZE;
			}
			//content_pic = json.getString("image");
			//LogUtil.i(this, "content_pic="+content_pic);
			from = json.getString("from");
			redirect = json.getInt("count");
			comment = json.getInt("mcount");
			if (!json.isNull("source"))
			{
				statuse = new Statuse(json.getJSONObject("source"));
			}
			
			
		}
		catch (JSONException e)
		{
			e.printStackTrace();
		}
		
	}

	public Long getId()
	{
		return id;
	}
	public void setId(Long id)
	{
		this.id = id;
	}
	public String getHead()
	{
		return head;
	}
	public void setHead(String head)
	{
		this.head = head;
	}
	public String getuName()
	{
		return uName;
	}
	public void setuName(String uName)
	{
		this.uName = uName;
	}
	public boolean isVerified()
	{
		return isVerified;
	}
	public void setVerified(boolean isVerified)
	{
		this.isVerified = isVerified;
	}
	public String getTime()
	{
		return time;
	}
	public void setTime(String time)
	{
		this.time = time;
	}
	public String getContent()
	{
		return content;
	}
	public void setContent(String content)
	{
		this.content = content;
	}
	public String getContent_pic()
	{
		return content_pic;
	}
	public void setContent_pic(String content_pic)
	{
		this.content_pic = content_pic;
	}
	public String getFrom()
	{
		return from;
	}
	public void setFrom(String from)
	{
		this.from = from;
	}
	public int getRedirect()
	{
		return redirect;
	}
	public void setRedirect(int redirect)
	{
		this.redirect = redirect;
	}
	public int getComment()
	{
		return comment;
	}
	public void setComment(int comment)
	{
		this.comment = comment;
	}
	public Statuse getStatuse()
	{
		return statuse;
	}
	public void setStatuse(Statuse statuse)
	{
		this.statuse = statuse;
	}

	public long getTimestamp()
	{
		return timestamp;
	}

	public void setTimestamp(long timestamp)
	{
		this.timestamp = timestamp;
	}
	
	

}
